@extends('layouts.frontend-iframe-base')


@section('css')
@stop

@section('content')
        <!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        个人中心
        <small>修改密码</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li class="active">首页</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">

    <!-- Your Page Content Here -->
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header with-border">
                    <h3 class="box-title">修改密码</h3>
                </div>
                <!-- /.box-header -->
                <!-- form start -->
                <form class="form-horizontal" id="J-form" action="/frontend/user/change-password" method="post">
                    <div class="box-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">旧密码</label>

                            <div class="col-sm-10">
                                <input name="old_password" type="password" class="form-control" placeholder="旧密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">新密码</label>

                            <div class="col-sm-10">
                                <input name="new_password" type="password" class="form-control" placeholder="新密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">再次输入新密码</label>

                            <div class="col-sm-10">
                                <input name="new_password2" type="password" class="form-control" placeholder="再次输入新密码">
                            </div>
                        </div>

                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <button type="submit" class="btn btn-info pull-right">提交</button>
                    </div>
                    <!-- /.box-footer -->
                </form>
            </div>

        </div>
    </div>

</section>
<!-- /.content -->


@stop

@section('js')
    <script>
        $(function () {

            $('#J-form').ajaxForm({
                beforeSubmit: function (data) {
                    if (data[1].value != data[2].value) {
                        alert('两次密码不一致！');
                        return false;
                    }
                    validator_info_clear($('#J-form'));
                },
                success: function (data) {
                    if (data.status == 1) {
                        alert('修改成功！');
                        window.location.href = '/frontend/user/profile';
                    } else {
                        alert(data.error_msg);
                    }
                },
                error: function (xhr) {
                    validator_info_show($('#J-form'), xhr);
                }
            });
        });


    </script>
@stop